home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 8323 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.6 KB  |  45 lines

  1. Path: news.u.washington.edu!trstedl
  2. From: trstedl@u.washington.edu (Todd Stedl)
  3. Newsgroups: comp.lang.c,comp.lang.c++
  4. Subject: GPF in BC++ 4.5
  5. Date: 16 Feb 1996 20:18:23 GMT
  6. Organization: University of Washington, Seattle
  7. Message-ID: <4g2oqf$sjc@nntp5.u.washington.edu>
  8. NNTP-Posting-Host: homer01.u.washington.edu
  9. NNTP-Posting-User: trstedl
  10.  
  11. I'm having problems with a General Protection Exception that I 
  12. continually get from a program I run in Borland C++ 4.5.  The reason I'm 
  13. cross posting to the C group is b/c it's a standard C program.  I've 
  14. looked at Borland's Web site but found no help there.
  15.  
  16. Here's the basics of the program:
  17. I use a lot of arrays and need to write to 2 separate data files, so I 
  18. allocate the memory accordingly.  I allocate the the file names as 
  19. pointers to char since their names may change depending upon certain 
  20. parameters in the program.
  21.     char *over_name, *data_name;
  22.  
  23. In the main program I reserve memory for the names.
  24.     over_name = (char*)malloc(20*sizeof(char));
  25.     data_name = ...
  26.  
  27. And the very last thing I do in main is free the memory.
  28.     free(over_name);
  29.     etc.
  30.  
  31. At that point I'm also freeing all the arrays I've used, too.
  32.  
  33. Now, whenever the program executes the free(over_name) line, I get the 
  34. following runtime error:
  35.     General Protection Exception
  36.     0xhhhh:0x4FBD
  37.     LAN(1) 0xhhhh:0x4FBD  Processor Fault
  38.  
  39. where hhhh is some hex number, but the 0x4FBD is always the same.  LAN is 
  40. the name of my project.
  41.  
  42. The thing that gets me is that the GPF occurs *only* when the program 
  43. executes free(over_name) !  It doesn't matter if it's the first item I 
  44. free or the last; it doesn't matter where I allocate the memory for it;
  45.